<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8" />
	<title>书店管理系统</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" type="text/css" href="/public/css/bootstrap.min.css" />
	<link rel="stylesheet" type="text/css" href="/public/css/swiper.min.css" />
	<link href="http://cdn.bootcss.com/animate.css/3.5.2/animate.min.css" rel="stylesheet" media="all">
	<link href="/public/css/bootstrap-touch-slider.css" rel="stylesheet" media="all">
	<link rel="stylesheet" type="text/css" href="/public/css/pc.css" />
	<link rel="stylesheet" type="text/css" media="screen and (max-width:1200px)" href="/public/css/ipad.css">
	<link rel="stylesheet" type="text/css" media="screen and (max-width:768px)" href="/public/css/phone.css">
	<script type="text/javascript" src="/public/js/jquery-1.11.1.min.js"></script>
	<script type="text/javascript" src="/public/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="/public/js/swiper.min.js"></script>
	<script type="text/javascript" src="/public/js/scrollReveal.js"></script>
	<script src="http://cdn.bootcss.com/jquery.touchswipe/1.6.18/jquery.touchSwipe.min.js"></script>
	<script src="/public/js/bootstrap-touch-slider-min.js"></script>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=Diy1GpUowSnG4kyw93KWvG4GfQDm3xch"></script>

	<!-- 地区插件 -->
	<script src="/public/js/distpicker.data.js"></script>	
	<script src="/public/js/distpicker.js"></script>
	<script src="/public/js/main.js"></script>	

	<script type="text/javascript" src="/public/js/jquery.cookie.js"></script>
	<script type="text/javascript" src="/public/js/base64.js"></script>
	<script type="text/javascript" src="/public/js/xiuzhen.js"></script>
	<script>
		if ($(document.body).width() < 760) {
			document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
		} else {
			document.documentElement.style.fontSize = document.documentElement.clientWidth / 1 + 'px';
		}
	</script>
	<!--兼容ie8-->
	<!--[if lt IE 9]>
	    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
	    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
	<!-- 头部导航开始 -->
	<div class="header">
		<div class="nav">
			<img class="logo" src="/public/images/logo.png" alt="">
			<ul class="top">
				<li>
					<a href="index.html">首页</a>
				</li>
				<li>
					<a href="box.html">图书展示</a>
				</li>
				<li>
					<a href="labOne.html">图书资讯</a>
			
				</li>
				
				<li>
					<a href="about.html">关于我们</a>
				</li>
				<li>
					<a href="contact.html">联系我们</a>
				</li>
			</ul>
			<div class="right">
				<a href="login.html" class="login">会员登陆</a>
				
				<a class="indexCart" href="cart.html">
					<img class="cart" src="/public/images/cart.png" alt="">
				</a>
				<a class="leaguer" href="member.html" style="display: none;">
					<img class="" src="/public/images/people2.png" alt="">
				</a>
				<p id="username" style="display: none;"></p>
				<!-- <p class="line"></p>
				<img class="weixin" src="images/weixin.png" alt=""> -->
			</div>
		</div>
	</div>

	<!--申请代售-->
	<div class="saleApply">
		<p class="title">申请代售</p>
		<form action="" id="sale">
			<div class="form">
				<input type="text" class="bgPicture1" name="bgPicture" hidden value="">
				<input type="text" class="hasPicture1" name="hasPicture" hidden value="">
				<input type="text" class="type" name="type" hidden value="代售">
				<input type="text" class="userId" name="userId" hidden value="">
				<input type="text" class="commodityId" name="commodityId" hidden value="">
				<div class="item">
					<p class="name">书名</p>
					<input type="text" name="caption" class="form-control caption" placeholder="填写书名">
				</div>
				<div class="item">
					<p class="name">简介</p>
					<input type="text" name="content" class="form-control content" placeholder="填写简介">
				</div>
				<div class="item">
					<p class="name">原价</p>
					<input type="text" name="originalPrice" class="form-control originalPrice" placeholder="填写原价">
				</div>
				<div class="item">
					<p class="name">现价</p>
					<input type="text" name="nowPrice" class="form-control nowPrice" placeholder="填写现价">
				</div>
				<div class="item">
					<p class="name">库存</p>
					<input type="text" name="stock" class="form-control stock" placeholder="填写库存">
				</div>
				<!--<div class="item">
					<p class="name">出版时间</p>
					<input type="text" name="recommendSecond" class="form-control recommendSecond" placeholder="填写出版时间">
				</div>-->
				<div class="item img">
					<p class="name">缩略图</p>
					<div class="top">
						<img class="avatarImg bgPicture" src="/public/images/grey.png" alt="">
						<div class="upload">
							<p>上传新的缩略图</p>
							<input type="file" accept="image/jpeg,image/jpg,image/png" id="bgPicture">
							<p>允许的文件类型JPG、GIF和PNG，最大文件尺寸为2MB</p>
						</div>
					</div>
				</div>
				<div class="item img">
					<p class="name">展示图</p>
					<div class="top">
						<img class="avatarImg hasPicture" src="/public/images/grey.png" alt="">
						<div class="upload">
							<p>上传新的展示图</p>
							<input type="file" accept="image/jpeg,image/jpg,image/png" id="hasPicture">
							<p>允许的文件类型JPG、GIF和PNG，最大文件尺寸为2MB</p>
						</div>
					</div>
				</div>
				<div class="item">
					<p class="name">描述</p>
					<textarea rows="5" cols="20" style="resize:none;padding:20px;"  name="detail" class="form-control recommendSecond detail"  placeholder="输入书的描述"></textarea>
				</div>
				<a href="javascript:;" class="apply">提交申请</a>
			</div>
		</form>
	</div>
	


	<!-- 预约弹框样式 -->
	<div class="appointShadow"></div>


	<!-- 右侧弹框 -->
	<div class="rightFrame">
		<div class="bespoke"><a href="saleApply.html">代售申请</a></div>
		<div class="placement"><img src="/public/images/top.png" alt="">置顶</div>
	</div>

		
	<!-- 弹框样式 -->
	<div class="alert-box">
		<span class="xz-alert alert alert-danger"></span>
	</div>
	
	<!-- 公共底部开始 -->
	<div class="footer">
		<div class="footer-content1">
			<div></div>
		</div>
		<div class="footer-content">
			<div class="container">
				<div class="content">
					<div class="left">
						<img class="bottom-logo" src="/public/images/logo.png" alt="">
						<p class="des">此系统为不仅为人们提供了便利的购书平台，还在此基础上增加了代售和出租的功能，人们有想卖的书籍可以在此平台申请，平台会帮忙代售，还有的宝宝们，不想购买书籍，此平台提供了租书的功能，不需要购买就可以便宜看到自己想看的书籍啦！！！</p>
					</div>
					<div class="right">
						<div class="contact">
							<p class="title">联系我们</p>
							<p class="phone">电话：0755-23324516</p>
							<p class="email">邮箱：cd.01@oil-com.com</p>
							<p class="email">QQ：1056598469</p>
						</div>
					</div>
				</div>
				<p class="copy">地址：山西省太原市万柏林区下元街道公园时代城2号楼1301</p><br>
			</div>
		</div>	
		
	</div>

	<script type="text/javascript">
	

		var loginUrl = Base64.encode("register.html");  
		$('.header .nav .right .login').attr('href','./login.html?loginurl='+loginUrl);
		$('.register .backLogin').attr('href','./login.html?loginurl='+loginUrl);
		
		// 点击返回顶部
		$('.rightFrame .placement').on('click', function () {
			$("html,body").animate({
				scrollTop: 0
			}, 1000);
		});
		
		
		
		
		$(function(){
			// 缩略图上传
			var uploading = false;
			$("#bgPicture").on("change", function(){
				if(uploading){
					$(".xz-alert").html("文件正在上传中，请稍候");
					$('.xz-alert').show();
					setTimeout(function () {
						$(".xz-alert").hide();
					}, 3000);
					return false;
				}
				var dat = new FormData();
				dat.append('file', $('#bgPicture').get(0).files[0]);

				$.ajax({
					url: url + '/common/upload',
					type: 'POST',
					cache: false,
					data: dat,
					processData: false,
					contentType: false,
					dataType:"json",
					beforeSend: function(){
						uploading = true;
					},
					success : function(data) {
						if (data.resultStatus) {
							$(".bgPicture").attr('src',data.resultData); 
							$(".bgPicture1").val(data.resultData);
						} else {
							showError(data.errorMessage);
						}
						uploading = false;
					},
					error: function () {
						$(".xz-alert").html("数据加载有误，重新加载中.....");
						$('.xz-alert').show();
						setTimeout(function () {
							$(".xz-alert").hide();
						}, 2000);
					}

				});
			});
			
			// 展示图上传
			var uploading1 = false;
			$("#hasPicture").on("change", function(){
				if(uploading1){
					$(".xz-alert").html("文件正在上传中，请稍候");
					$('.xz-alert').show();
					setTimeout(function () {
						$(".xz-alert").hide();
					}, 3000);
					return false;
				}
				var dat = new FormData();
				dat.append('file', $('#hasPicture').get(0).files[0]);

				$.ajax({
					url: url + '/common/upload',
					type: 'POST',
					cache: false,
					data: dat,
					processData: false,
					contentType: false,
					dataType:"json",
					beforeSend: function(){
						uploading1 = true;
					},
					success : function(data) {
						if (data.resultStatus) {
							$(".hasPicture").attr('src',data.resultData); 
							$(".hasPicture1").val(data.resultData);
						} else {
							showError(data.errorMessage);
						}
						uploading1 = false;
					},
					error: function () {
						$(".xz-alert").html("数据加载有误，重新加载中.....");
						$('.xz-alert').show();
						setTimeout(function () {
							$(".xz-alert").hide();
						}, 2000);
					}

				});
			});
			
			
			$("#sale .apply").click(function(){
				if(!$.cookie('uid')){
					location.href = './login.html';
				}else{
					$("#sale .userId").val( $.cookie('uid') ) 
					$("#sale .commodityId").val( "0" ) 
					if($("#sale .caption").val() == ""){
						$(".xz-alert").html("书名不能为空！");
						$('.xz-alert').show();
						setTimeout(function () {
							$(".xz-alert").hide();
						}, 1000);
					}else if($("#sale .content").val() == ""){
						$(".xz-alert").html("简介不能为空!");
						$('.xz-alert').show();
						setTimeout(function () {
							$(".xz-alert").hide();
						}, 1000);
					}else if($("#sale .originalPrice").val() == ""){
						$(".xz-alert").html("原价不能为空!");
						$('.xz-alert').show();
						setTimeout(function () {
							$(".xz-alert").hide();
						}, 1000);
					}else if($("#sale .nowPrice").val() == ""){
						$(".xz-alert").html("现价不能为空!");
						$('.xz-alert').show();
						setTimeout(function () {
							$(".xz-alert").hide();
						}, 1000);
					}else if($("#sale .stock").val() == ""){
						$(".xz-alert").html("库存不能为空!");
						$('.xz-alert').show();
						setTimeout(function () {
							$(".xz-alert").hide();
						}, 1000);
					}else{
						$.ajax({
							type: "post",
							dataType: "json", // submit info
							url: url + '/web/commodity',
							data:$("#sale").serializeArray(),
							contentType:"application/x-www-form-urlencoded",
							success: function (res) {
								if (!res.resultStatus) {
									$(".xz-alert").html(res.errorMessage);
									$('.xz-alert').show();
									setTimeout(function () {
										$(".xz-alert").hide();
									}, 1000);
									return
								}
								$(".xz-alert").html("提交成功！");
								$('.xz-alert').show();
//								setTimeout(function () {
//									$(".xz-alert").hide();
//									location.href = './index.html';
//								}, 1000);
	
								
								
							},
							error: function (e) {
								$(".xz-alert").html("数据格式不正确，重新填写");
								$('.xz-alert').show();
								setTimeout(function () {
									$(".xz-alert").hide();
								}, 1000);
							}
					
						})
					}
				}
				
				
			})
		})
		
		


		
	</script>		

</body>

</html>